home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
ultratk.exe
/
ULTRA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-19
|
8KB
|
265 lines
/* ultra.c
These functions are Turbo C implementations of many of the extended
BIOS routines provided with UltraVision(r), version 2.0. Several
of the functions herein make use of the files VIDEO.C & VIDEO.H
recently uploaded by the author.
COMPILE SEPARATELY. LINK EXE FILES WITH VIDEO.OBJ & ULTRA.OBJ
Tom Kallal, 4150 Sovereign Way, Salt Lake City UT 84124.
*/
#include "ultra.h"
#include "video.h"
#include <dos.h>
#include <conio.h>
extern video_status CRT; /* a global */
int ultra_loaded ( void )
{
/* Return 1 if UV is loaded, 0 if not loaded. */
_AH = 0xcc; /* Get UV status */
_AL = 0x00;
geninterrupt ( 0x10 );
if ( _CX == 0xabcd ) return ( TRUE ); /* UV is loaded */
else return ( FALSE );
}
int ultra_active ( void )
{
/* Return 1 if UV is loaded AND active, 0 otherwise. */
_AH = 0xcc; /* Get UV status */
_AL = 0x00;
geninterrupt ( 0x10 );
if (( _AL==0 )&&( _CX==0xabcd )) return ( TRUE );
else return ( FALSE );
}
int get_ultra_card ( void )
{
/* Return the video card code ( 0 - 27 ) if UltraVision is loaded,
else return FAIL. If needed, this function should be called just
once at startup.
*/
_AH = 0xcc; /* Get UV status */
_AL = 0x00;
geninterrupt ( 0x10 );
if ( _CX == 0xabcd ) return ( _AH ); /* if loaded, return card # */
else return ( FAIL );
}
int get_ultra_mode ( void )
{
/* Return the current UV text mode if UV is loaded and active,
else return FAIL .
*/
if ( ultra_active() ) { /* Is UV loaded AND active ? */
_AH = 0xcd;
_AL = 0x04;
geninterrupt ( 0x10 );
return _AL;
}
return (FAIL);
}
/* NOTE: The rest of the functions in this file refer to variables
and functions found in VIDEO.C and VIDEO.H. With the
exception of the functions bump_rows() and bump_cols(),
it would be easy to remove these references and still have
a complete working set of functions for UltraVision text
modes. The idea of combining this file with VIDEO.C is to
have a complete set of Turbo C text mode video functions
that are compatible with any monitor, whether running
UltraVision or not.
*/
int set_ultra_mode ( int uv_mode )
{
/* Set a special UV text mode. Return the mode requested if successful,
else return FAIL. Calling this function directly requires knowing
the video card in place and its mode capabilities.
*/
if ( ultra_active() ) {
_AH = 0xcd;
_AL = uv_mode; /* set UV text mode */
geninterrupt ( 0x10 );
if ( _AX != 0xcdcd ) { /* CDCD == mode error */
get_video_status(); /* NOTE: this function call updates */
/* the global struct CRT in video.h */
/* REMOVE IF DESIRED */
return (uv_mode);
}
}
return (FAIL);
}
int enable_ultra ( void )
{
/* Enable UltraVision, if loaded and inactive. */
if (( ultra_loaded() )&&( !ultra_active() )) {
_AH = 0xcc;
_AL = 0x02;
geninterrupt ( 0x10 ); /* enable UV */
_AH = 0x00;
_AL = CRT.mode; /* reset to global CRT */
geninterrupt ( 0x10 );
get_video_status(); /* NOTE: this function call updates */
/* the global struct CRT in video.h */
/* REMOVE IF DESIRED */
return ( SUCCESS );
}
return ( FAIL );
}
int disable_ultra ( void )
{
/* Disable UltraVision, if loaded. Reset CRT mode to former
standard mode, ie, CO80, BW80, or C4350.
*/
if (( ultra_loaded() )&&( ultra_active() )) {
_AH = 0xcc;
_AL = 0x01;
geninterrupt ( 0x10 ); /* disable UV */
_AH = 0x00;
_AL = CRT.mode; /* reset to global CRT */
geninterrupt ( 0x10 );
get_video_status(); /* NOTE: this function call updates */
/* the global struct CRT in video.h */
/* REMOVE IF DESIRED */
return ( SUCCESS );
}
return ( FAIL );
}
int bump_rows ( int plus_minus )
{
/* Rather than trying to call set_ultra_mode() directly, this function
simply does a "blind bump" of the row count until it achieves success;
it does not change the column count.
If UltraVision is active, it returns the new UV mode, else it returns
FAIL. Note that it works even if UltraVision is not installed.
*/
int col_mode, row_mode;
if ( ultra_active() ) {
if ( plus_minus >=0 ) plus_minus = 1; /* +1 or -1 only */
else plus_minus =-1; /* no zeros allowed! */
col_mode = COL_MODE(CRT.cols); /* macros in ultra.h */
row_mode = ROW_MODE(CRT.rows);
do {
row_mode+=plus_minus;
if ( row_mode > 3 ) row_mode=0; /* wrap it around */
if ( row_mode < 0 ) row_mode=3; /* ditto */
} while (( set_ultra_mode ( UV_MODE[col_mode][row_mode] ))==FAIL);
return ( UV_MODE[col_mode][row_mode] );
}
else { /* either UV is inactive or not present */
if ( CRT.color ) {
if ( CRT.rows == 25 ) textmode ( C4350 ); /* give it a try */
else textmode ( C80 );
}
else {
if ( CRT.rows == 25 ) textmode ( C4350 ); /* give it a try */
else textmode ( BW80 );
}
get_video_status(); /* update the global CRT */
}
return ( FAIL );
}
int bump_cols ( int plus_minus )
{
/* Rather than trying to call set_ultra_mode() directly, this function
simply does a "blind bump" of the col count until it achieves success;
it does not change the row count.
If UltraVision is active, it returns the new UV mode, else it returns
FAIL. Note that it works even if UltraVision is not installed.
*/
int col_mode, row_mode;
if ( ultra_active() ) {
if ( plus_minus >=0 ) plus_minus = 1;
else plus_minus =-1;
col_mode = COL_MODE(CRT.cols);
row_mode = ROW_MODE(CRT.rows);
do {
col_mode+=plus_minus;
if ( col_mode > 4 ) col_mode=0;
if ( col_mode < 0 ) col_mode=4;
} while (( set_ultra_mode ( UV_MODE[col_mode][row_mode] ))==FAIL);
return ( UV_MODE[col_mode][row_mode] );
}
else { /* either UV is inactive or not present */
if ( CRT.color ) {
if ( CRT.cols == 80 ) textmode ( C40 );
else textmode ( C80 );
}
else {
if ( CRT.cols == 80 ) textmode ( BW40 );
else textmode ( BW80 );
}
get_video_status(); /* update the global CRT */
}
return ( FAIL );
}
/* end ultra.c */